<template>
  <div>
    <el-dialog
      :title="typeof userdata.id == 'number' ? '修改' : '新增'"
      :visible.sync="dialogVisible"
      :modal="false"
      width="40%"
      :before-close="handleClose"
    >
      <Form :itemModel="userdata" ref="Form" />
      <span slot="footer" class="dialog-footer">
        <el-button @click="continueComfirm">继续添加</el-button>
        <el-button @click="close">取 消</el-button>
        <el-button type="primary" @click="comfirm">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import Form from "./form.vue";
export default {
  components: {
    Form,
  },
  props: {
    userdata: {
      type: Object,
      default: () => {
        return {};
      },
    },
  },
  data() {
    return {
      dialogVisible: false,
    };
  },
  methods: {
    comfirm() {
      this.$emit("change", this.$refs.Form.getForm());
      this.close();
      return this
    },
    open() {
      this.dialogVisible = true;
      return this
    },
    close() {
      this.dialogVisible = false;
      this.$emit('change')
      return this
    },
    continueComfirm(){
      this.$emit("change", this.$refs.Form.getForm());
      return this
    },
    handleClose(done) {
      this.$confirm("确认关闭？").then(() => {
        this.close();
      });
      return this
    },
  },
};
</script>

<style>
 .avatar-uploader .el-upload {
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
  }
  .avatar-uploader .el-upload:hover {
    border-color: #409EFF;
  }
  .avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
    width: 178px;
    height: 178px;
    line-height: 178px;
    text-align: center;
  }
  .avatar {
    width: 178px;
    height: 178px;
    display: block;
  }
</style>